/* $RCSFile: AssemblyResourceManager.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.ServerControls/LicenceControls/AssemblyResourceManager.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:30  christian.surieux
 *   Added Log to All cs files
 */

// AssemblyResourceManager.cs
// Server Controls and Components
//

using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;

namespace ADNCRM.ServerControls 
{

    internal sealed class AssemblyResourceManager 
	{

        private static ResourceManager _resources;

        private AssemblyResourceManager() {}

        private static void EnsureResources() 
		{
            if (_resources == null) 
			{
                try 
				{
                    _resources = new ResourceManager("ADNCRM.ServerControls.Properties.Resources",typeof(AssemblyResourceManager).Assembly);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"AssemblyResourceManager EnsureResources Ex: {0}", ex));
                }

            }
        }

        public static object GetObject(string name) {
            return GetObject(null, name);
        }

        public static object GetObject(CultureInfo culture, string name) 
		{
            EnsureResources();
            if (_resources != null) 
                return _resources.GetObject(name, culture);
            return null;
        }
        
        public static string GetString(string name) 
		{
            return GetString(null, name);
        }

        public static string GetString(CultureInfo culture, string name) 
		{
            EnsureResources();
            if (_resources != null) 
                return _resources.GetString(name, culture);
            return null;
        }
    }
}
